package com.example.ResumeWorkPlatform.dao;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;


/**
 * @ClassName: DepartmentEntity
 * @Description: 部门实体
 * @Copyright: smartlab411
 * @Author chengwenixng
 * @Date 2020-3-29 1:23
 */

@Entity
@Table(name = "department_entity")
public class DepartmentEntity implements Serializable {

	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Long departmentId;

	/**
	 * 部门名称
	 */
	private String departmentName;
	/**
	 * 删除标识符
	 */
	private boolean delFlag = true;

	/**
	 * 创建时间
	 */
	private Date createTime = new Date();
	/**
	 * 工业园区和部门（多对一）;
	 */
	@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
	private GerdenEntity gerdenEntity;
	
	/**
	 * 部门-用户（一对多）;
	 */
	@OneToMany(mappedBy = "departmentEntity", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
	private List<BasicUserEntity> basicUserEntities= new ArrayList<>();

	public Long getDepartmentId() {
		return departmentId;
	}

	public void setDepartmentId(Long departmentId) {
		this.departmentId = departmentId;
	}

	public String getDepartmentName() {
		return departmentName;
	}

	public void setDepartmentName(String departmentName) {
		this.departmentName = departmentName;
	}

	public boolean isDelFlag() {
		return delFlag;
	}

	public void setDelFlag(boolean delFlag) {
		this.delFlag = delFlag;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public GerdenEntity getGerdenEntity() {
		return gerdenEntity;
	}

	public void setGerdenEntity(GerdenEntity gerdenEntity) {
		this.gerdenEntity = gerdenEntity;
	}

	public List<BasicUserEntity> getBasicUserEntities() {
		return basicUserEntities;
	}

	public void setBasicUserEntities(List<BasicUserEntity> basicUserEntities) {
		this.basicUserEntities = basicUserEntities;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((basicUserEntities == null) ? 0 : basicUserEntities.hashCode());
		result = prime * result + ((createTime == null) ? 0 : createTime.hashCode());
		result = prime * result + (delFlag ? 1231 : 1237);
		result = prime * result + ((departmentId == null) ? 0 : departmentId.hashCode());
		result = prime * result + ((departmentName == null) ? 0 : departmentName.hashCode());
		result = prime * result + ((gerdenEntity == null) ? 0 : gerdenEntity.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		DepartmentEntity other = (DepartmentEntity) obj;
		if (basicUserEntities == null) {
			if (other.basicUserEntities != null)
				return false;
		} else if (!basicUserEntities.equals(other.basicUserEntities))
			return false;
		if (createTime == null) {
			if (other.createTime != null)
				return false;
		} else if (!createTime.equals(other.createTime))
			return false;
		if (delFlag != other.delFlag)
			return false;
		if (departmentId == null) {
			if (other.departmentId != null)
				return false;
		} else if (!departmentId.equals(other.departmentId))
			return false;
		if (departmentName == null) {
			if (other.departmentName != null)
				return false;
		} else if (!departmentName.equals(other.departmentName))
			return false;
		if (gerdenEntity == null) {
			if (other.gerdenEntity != null)
				return false;
		} else if (!gerdenEntity.equals(other.gerdenEntity))
			return false;
		return true;
	}
	
	
	
}
